package utils
{
	import mx.core.UIComponent;

	import modules.componentpanel.htmlcomponents.HTMLBasicLayout;
	import modules.componentpanel.htmlcomponents.HTMLButton;
	import modules.componentpanel.htmlcomponents.HTMLHorizontalLayout;
	import modules.componentpanel.htmlcomponents.HTMLVerticalLayout;

	public class HTMLItemCreateUtil
	{
		public static var createPackage:String="utils.creation.";
		public static var suffix:String="CreateUtil";

		public static function createHTMLItem(name:String):UIComponent
		{
			var component:UIComponent;
			if (GlobalConfig.ICON_BUTTON_BUTTON == name)
			{
				component=new HTMLButton();
			}
			else if (GlobalConfig.ICON_BUTTON_BASIC_LAYOUT == name)
			{
				component=new HTMLBasicLayout();
			}
			else if (GlobalConfig.ICON_BUTTON_HORIZONTAL_LAYOUT == name)
			{
				component=new HTMLHorizontalLayout();
			}
			else if (GlobalConfig.ICON_BUTTON_VERTICAL_LAYOUT == name)
			{
				component=new HTMLVerticalLayout();
			}
			if (component == null)
			{
				throw Error(name + "is not implemented yet!!!");
			}
			return component;
		}

	/**
	 * using this method would also need to add the required Class in build config, otherwise the flex compiler won't add them to the swf.
	 */
	/*public static function createHTMLItemByName(name:String):UIComponent{
	var component:UIComponent;
	if(name != null && name.replace(" ","") != ""){
	var utilClassName:String = createPackage+name+suffix;
	var ci:ClassInfo = ClassInfo.forName(utilClassName);
	var m:Method = ci.getStaticMethod("create");
	component= m.invoke(null,[]);
	trace("createHTMLItemByName: "+component.toString());
	}
	return component;
	}*/
	}
}
